{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>新建</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择学校：</label>
                            <div class="layui-input-block">
                                <select name="ts_school_erp" lay-verify="required" lay-search>
                                <option value="">请选择</option>
                                {foreach name="schools" item="v"}
                                <option value="{$v.school_erp}">{$v.school_name}</option>
                                {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">年份：</label>
                            <div class="layui-input-block">
                                <input type="text" name="ts_year" lay-verify="number" placeholder="请填写年份" value="" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">年级：</label>
                            <div class="layui-input-block">
                                <input type="text" name="ts_grade" lay-verify="required" placeholder="请填写年级" value="" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">开始日期</label>
                            <div class="layui-input-block">
                                <input type="text" name="ts_begin" onclick="wk.lay_date_ymd(this);" placeholder="开始日期" class="layui-input layer-date">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">截止日期</label>
                            <div class="layui-input-block">
                                <input type="text" name="ts_end" onclick="wk.lay_date_ymd(this);" placeholder="截止日期" class="layui-input layer-date">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">统购金额：</label>
                            <div class="layui-input-block">
                                <input type="number" min="0" step="0.01" name="ts_money" placeholder="统购金额（不含邮费）" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">邮费：</label>
                            <div class="layui-input-block">
                                <input type="number" min="0" step="0.01" name="ts_post" value="0" placeholder="为0即为包邮" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">交期(天数)：</label>
                            <div class="layui-input-block">
                                <input type="number" min="1" step="1" name="ts_done" value="24" placeholder="交期（单位为天）" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">学生名单：</label>
                            <div class="layui-input-block">
                                <textarea name="ts_student" class="layui-input" style="height: 100px" placeholder="如设置学生名单，请输入学生姓名，以英文逗号','隔开，如不设置，则此学校此入学年份的所有学生都可购买"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form','upload','layedit','laydate'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('activeAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        $("button").removeClass('layui-disabled').removeAttr('disabled');
                        wk.error(res.msg);
                        return false;
                    }
                }
            })
        });
    });
</script>

</body>
</html>
